import { createRouter, createWebHashHistory } from "vue-router";
const homePage = () => import(/* webpackChunkName: "group-home" */ "@/pages/homePage/index.vue");
const songpage = () => import(/* webpackChunkName:"group-songpage"*/ "@/pages/songPage/SongPage.vue");
const errorPage = () => import(/* webpackChunkName:"group-err"*/ "@/pages/error/ErrorPage.vue");
const playlist = () => import(/* webpackChunkName:"group-playlist"*/ "@/pages/playList/PlayListPage.vue");
const searchPage = () => import(/* webpackChunkName:"group-searchpage"*/ "@/pages/searchPage/SearchPage.vue");
const router = createRouter({
    history: createWebHashHistory(),
    routes: [
        {
            name: "homePage",
            path: "",
            component: homePage
        },
        {
            name: "songpage",
            path: "/song",
            component: songpage
        },
        {
            name: "playList",
            path: "/playlist",
            component: playlist
        },
        {
            name: "search",
            path: "/search",
            component: searchPage
        },
        {
            name: "err",
            path: '/:err(.*)',
            component: errorPage
        }
    ],
    scrollBehavior() {
        return new Promise(function (resolve) {
            setTimeout(() => {
                const m = document.getElementById("main");
                m.scrollTop = 0;
                resolve()
            }, 500)
        })
    }

})

export default router